package com.wt.springsamples.schedule;


import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

@EnableScheduling
@Component
@Slf4j
public class TestScheduleJobs {

//    @Scheduled(cron = "0/10 * * ? * ?")
    public void cron() {
        //https://docs.spring.io/spring-framework/docs/5.3.39/reference/html/integration.html#scheduling
        log.info("定时执行，时间{}",LocalDateTime.now());
//        System.out.println("定时执行，时间==="+LocalDateTime.now());
        this.addRender(new FileSyncHandler() {
            @Override
            public String syncFile() {
                return null;
            }
        });
    }

    public  void addRender(FileSyncHandler handler){
        handler.syncFile();
    }
}
